<template>
  <!-- 客户信息管理 -->
  <div>
    <custom-container ref="customContainerRef" :config="mainConfig"></custom-container>
    <!-- 添加或修改参数配置对话框 -->
    <setform
      ref="setFormRef"
      :ids="ids"
      @changeList="handleQuery"
    />
    <!-- 特殊产品组件 -->
    <specialProduct
      v-if="productId!=undefined"
      ref="specialProductList"
      v-model:specialOpen="specialOpen"
      v-model:specialTitle="specialTitle"
      v-model:productId="productId"
    />
    <!-- 账期 -->
    <el-dialog v-model="accountingPeriodOpen" :title="accTitle">
      <accountingPeriod
        v-if="accountingPeriodOpen&&productId!=undefined"
        ref="accountingPeriodRef"
        v-model:productId="productId"
      />
    </el-dialog>
    <!-- 批量修改客户等级 -->
    <el-dialog v-model="priceOpen" title="批量修改客户等级" :close-on-click-modal="false">
      <el-form ref="customerLevel" :model="gradeForm">
        <el-form-item label="客户等级" prop="grade">
          <el-select v-model="gradeForm.grade" clearable placeholder="请输入客户等级">
            <el-option
              v-for="dict in dicts[DictDirection.价格等级]"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div>
          <el-button type="primary" @click="submitCustomerLevel">确定</el-button>
          <el-button @click="cancelCustomerLevel">取消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 关联价格 -->
    <el-dialog v-model="priceImportO">
      <el-form ref="priceEditForm" :model="priceForm">
        <el-select v-model="priceForm.currentPriceList">
          <el-option
            v-for="price in priceList"
            :key="price.id"
            :value="price.id"
            :label="price.name"
          ></el-option>
        </el-select>
      </el-form>
      <template #footer>
        <div>
          <el-button type="primary" @click="submitPriceIm">确定</el-button>
          <el-button @click="cancelPriceIm">取消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 修改可预定方数 -->
    <el-dialog v-model="quantityOpen" title="修改可预定方数">
      <el-form ref="quantityEditForm" :model="quantityForm">
        <el-form-item label="可预订舱方数" prop="bookableProportion" :rules="[{ required: true, message: '必填', trigger: 'blur' }]">
          <el-tooltip effect="dark" content="-1表示无限制，0表示无法订舱，其他值表示可预定方数" placement="top">
            <el-input-number v-model="quantityForm.bookableProportion" :controls="false" :min="-1"></el-input-number>
          </el-tooltip>
        </el-form-item>
      </el-form>
      <template #footer>
        <div>
          <el-button type="primary" @click="quantitySubmit">确定</el-button>
          <el-button @click="quantityCancel">取消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 末端充值表单 -->
    <el-dialog v-model="openRecharge" title="充值末端额度" :close-on-click-modal="false">
      <el-row class="mb8" :gutter="10">
        <el-col :span="1.5">
          <el-button type="primary" @click="handleAddRecord">增加额度</el-button>
        </el-col>
      </el-row>
      <el-table
        v-loading="loading"
        border
        :data="tableData"
        height="300px"
      >
        <el-table-column label="充值时间" prop="rechargeTime" width="180" />
        <el-table-column label="充值金额" prop="rechargeAmount" width="180" />
        <el-table-column label="充值人" prop="rechargePerson" />
      </el-table>
      <el-dialog
        v-model="openLines"
        title="增加额度"
        width="25%"
        :close-on-click-modal="false"
      >
        <el-form
          ref="addLinesForm"
          label-width="100px"
          :rules="rulesLines"
          :model="addForm"
        >
          <el-form-item label="额度" prop="amount">
            <el-input
              v-model="addForm.amount"
              placeholder="请输入额度"
              clearable
              style="width: 240px;"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              size="small"
              type="primary"
              :loading="subLoading"
              @click="submitRecord"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
    </el-dialog>
    <!-- 批量修改业务员 -->
    <el-dialog v-model="salesmanOpen" title="修改业务员" width="400px">
      <el-form ref="salesmanForm" :model="salesForm">
        <el-form-item label="业务员" prop="businessManager">
          <el-select
            v-model.trim="salesForm.businessManager"
            filterable
            clearable
            placeholder="请输入业务员"
          >
            <el-option
              v-for="dict in dicts[DictDirection.员工信息]"
              :key="dict.id"
              :label="dict.nickName"
              :value="dict.userName"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div>
          <el-button type="primary" @click="handleSubSale">确定</el-button>
          <el-button @click="cancelSubSale">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script lang="ts" setup>
import { computed, ref, defineAsyncComponent, getCurrentInstance, reactive } from 'vue'
import { Plus, Edit, Delete, Search, Upload, Bottom, Key, UploadFilled } from '@element-plus/icons-vue'
import { ElButton, ElMessageBox, ElMessage, ElSwitch } from 'element-plus'
import { addDateRange, download2, replaceParams, resetForm, validateForm } from '@/utils'
import userDicts, { DictDirection } from '@/store/modules/dicts'
import { PutEnableQuotaEdit, passwordDecryption, editCustStatus, getData, delData, editData, addData, delImg, updataGrade, modifyBooking, 
  editSalemans, getRechargeRecord, editRecharge } from '@/api/clientManger'

import { customerPriceList, uploadPriceFile } from '@/api/customer/priceManage'

const setform = defineAsyncComponent(() => import('./components/setForm.vue'))
const specialProduct = defineAsyncComponent(() => import('./components/specialProduct.vue'))
const accountingPeriod = defineAsyncComponent(() => import('./components/accountingPeriod.vue'))
const dicts = userDicts()
/* 末端充值---开始 */
const validatePass = (rule, value, callback) => {
  const val = Number(value)
  if (isNaN(val)) {
    return callback('请输入数字')
  }
  if (val <= 0) {
    return callback('请输入有效数值')
  }
  return callback()
}
/* 末端充值----结束 */
const // 选中数组
  ids = ref([]),
  dateRange = ref([]),
  // 特殊产品弹出框
  specialOpen = ref(false),
  specialTitle = ref(''),
  customerCodes = ref([]),
  // 末端额度表单
  tableData = ref([]),
  // 末端额度表单显示
  loading = ref(false),
  // 非多个禁用
  multiple = ref(true),
  // 非单个禁用
  single = ref(true),
  // 修改客户等级表单状态
  priceOpen = ref(false),
  // 新增额度
  openLines = ref(false),
  // 价格关联
  priceImportO = ref(false),
  // 价格关联
  priceForm = ref({
    currentPriceList: undefined,
  }),
  // 价格关联
  priceId = ref([]),
  // 价格列表
  priceList = ref([]),
  // 账期表单状态
  accountingPeriodOpen = ref(false),
  // 查询
  queryParams = ref({
    pageNum: 1,
    pageSize: 10,
    custCodeList: undefined,
    wholeName: undefined,
    simpleName: undefined,
    status: undefined,
    grade: undefined,
    id: undefined,
  }),
  customContainerRef = ref(null),
  // 修改末端

  // 充值末端额度的表单显示
  openRecharge = ref(false),
  customerCode = ref(null),
  // 修改可预订方数
  customerCodeSpecial = [],
  // 修改可预订方表单
  quantityForm = ref({
    bookableProportion: undefined,
  }),
  // 批量修改客户等级
  gradeForm = ref({
    grade: undefined,
  }),
  // 批量修改业务员
  salesmanOpen = ref(false),
  salesForm = ref({
    businessManager: undefined,
  }),
  // 修改可预定方数
  quantityOpen = ref(false),
  // 新增修改表单
  // 新增末端表单确定的状态框
  subLoading = ref(false),
  // 末端额度充值
  addForm = ref({ amount: undefined }),
  recharge = ref(null),
  customerLevel = ref(null),
  quantityEditForm = ref(null),
  addLinesForm = ref(null),
  salesmanForm = ref(null),
  priceEditForm = ref(null),
  {
    appContext: {
      config: {
        globalProperties: { $resetForm, $validateForm },
      },
    },
  } = getCurrentInstance(),
  rulesLines = {
    amount: [
      { required: true, message: '必填', trigger: ['blur', 'change'] },
      { validator: validatePass, trigger: ['blur', 'change'] },
    ],
  }
/* 客户信息-----开始 */
// 查询客户信息列表
const handleQuery = () => {
  customContainerRef.value.getList()
}
/* 客户信息-----结束 */
/* 账期开始 */
const accountingPeriodRef = ref(null)
const productId = ref(null)
const tempAccountingPeriod = ref('')
const handleTransportType = () => {
  accountingPeriodOpen.value = true
  // accountingPeriodRef.value.idss=
  tempAccountingPeriod.value = 'accountingPeriod'
}
const handleIntermTransportType = () => {
  accountingPeriodOpen.value = true
  tempAccountingPeriod.value = 'temporaryAccounting'
}

const accTitle = computed(() => {
  let title = ''
  if (tempAccountingPeriod.value === 'accountingPeriod') {
    title = '账期'
  } else if (tempAccountingPeriod.value === 'temporaryAccounting') {
    title = '临时账期'
  } 
  return title
})
// 多选
const handleTableSelect = (rows: { [key: string]: any }[]) => {
  console.log(rows, 'ss')
  ids.value = rows.map((row) => row.id)
  productId.value = ids.value[0]
  customerCodes.value = rows.map((row) => row.customerCode)
  priceId.value = rows.map((row) => row.priceId)
  single.value = rows.length !== 1
  multiple.value = !rows.length
}
/* 账期结束 */

// 删除
const handleDelete = (row: { [key: string]: any }) => {
  let id = (row && row.id) || ids
  if (!Array.isArray(id)) {
    id = [id]
    console.log(id, '产品代码')
  }
  const customerCode = (row && row.customerCode) || customerCodes
  ElMessageBox.confirm(`是否删除产品代码为${ customerCode }的产品`, '警告', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
  .then(() => delData(id))
  .then((res) => {
    if (res.code == 200) {
      ElMessage.success('删除成功')
      handleQuery()
    } else {
      ElMessage.error('删除失败')
    }
  })
  .catch((err) => {
    if (err == 'cancel') {
      ElMessage.info('取消删除')
    }
  })
}
// 下载价格
const handleDownPriceExcl = (row: { [key: string]: any }) => {
  row.loading = true
  download2('/system/customer/download_price', { priceId: row.priceId }, `价格列表_${ new Date().getTime() }.xlsx`)
  row.loading = false
}
// 导出客户信息
const handleExport = () => {
  const data = { pageSize: 10, pageNum: 1 }
  download2('/system/customer/export_c_info', data, 'customerInformation.xlsx')
}
// 清空可预订方数
const resetQuantityForm = () => {
  quantityForm.value = {
    bookableProportion: undefined,
  }
  $resetForm(quantityEditForm.value)
}
// 修改可预订方数
const handleQuantity = () => {
  quantityOpen.value = true
}
// 清除修改可预订方数表单
const quantityCancel = () => {
  quantityOpen.value = false
  resetQuantityForm()
}
// 末端额度充值
const handleRecharge = (row: { [key: string]: any }) => {
  const rowList = JSON.parse(JSON.stringify(row))
  customerCode.value = rowList.customerCode
  console.log(customerCode.value)
  openRecharge.value = true
  getEndList()
}
// 增加额度
const handleAddRecord = () => {
  openLines.value = true
}
// 批量修改客户等级
const handleEditPrice = () => {
  priceOpen.value = true
}
// 修改可预订方数
const quantitySubmit = () => {
  $validateForm(quantityEditForm.value, () => {
    modifyBooking({
      ids: ids.value,
      bookableProportion: quantityForm.value.bookableProportion,
    }).then((res) => {
      if (res.code == 200) {
        quantityOpen.value = false
        resetQuantityForm()
        handleQuery()
        ElMessage.success('修改成功')
      } else {
        ElMessage.error('修改失败')
      }
    })
  })
}
// 获取末端额度的列表
const getEndList = () => {
  loading.value = true
  getRechargeRecord(customerCode.value)
  .then((res) => {
    if (res.code == 200) {
      tableData.value = res.data
      ElMessage.success('查询成功')
      loading.value = false
    } else {
      loading.value = false
      ElMessage.error('获取末端额度失败')
    }
  })
  .catch((err) => {
    if (err == 'cancel') {
      ElMessage.info('取消查询')
      loading.value = false
    }
  })
}
// 重置表单
const resetLines = () => {
  addForm.value = {
    amount: undefined,
  }
  $resetForm(addLinesForm.value)
}
// 确定增加额度
const submitRecord = () => {
  $validateForm(addLinesForm.value, () => {
    const data = { amount: addForm.value.amount, customerCode: customerCode.value }
    subLoading.value = true
    editRecharge(data)
    .then((res) => {
      if (res.code == 200) {
        ElMessage.success('操作成功')
        openLines.value = false
        subLoading.value = false
        resetLines()
        getEndList()
      } else {
        ElMessage.error('操作失败')
      }
    })
    .catch((err) => {
      if (err == 'cancel') {
        subLoading.value = false
        ElMessage.info('取消操作')
        resetLines()
      }
    })
  })
}
// 获取价格表
const getPriceList = () => {
  const data = { status: 1 }
  customerPriceList(data).then((res) => {
    if (res.code == 200) {
      priceList.value = res.data
    }
  })
}

// 打开批量修改业务员
const handleEditSalesman = () => {
  salesmanOpen.value = true
}
// 重置修改业务员
const resetSalesMan = () => {
  salesForm.value = {
    businessManager: undefined,
  }
  $resetForm(salesmanForm.value)
}
// 批量修改业务员
const handleSubSale = () => {
  $validateForm(salesmanForm.value, () => {
    const data = {
      ids: ids.value,
      businessManager: salesForm.value.businessManager,
    }
    editSalemans(data)
    .then((res) => {
      if (res.code == 200) {
        ElMessage.success('修改成功')
        salesmanOpen.value = false
        handleQuery()
        resetSalesMan()
      } else {
        ElMessage.error('修改失败')
      }
    })
    .catch((err) => {
      if (err == 'cancel') {
        ElMessage.info('取消修改')
        priceOpen.value = false
        resetSalesMan()
      }
    })
  })
}
// 取消批量删除
const cancelSubSale = () => {
  resetSalesMan()
  priceOpen.value = false
}
// 价格批量导入
const handlePriceImport = () => {
  priceImportO.value = true
  getPriceList()
}
// 重置价格批量导入表单
const resetpriceForm = () => {
  priceForm.value = {
    currentPriceList: undefined,
  }
  $resetForm(priceEditForm.value)
}

// 确定价格
const submitPriceIm = () => {
  if (priceForm.value.currentPriceList.length < 1) {
    ElMessage.error('未选择价格表!')
  } else {
    uploadPriceFile({ priceId: priceForm.value.currentPriceList, ids: ids.value }).then((res) => {
      if (res.code == 200) {
        priceImportO.value = false
        handleQuery()
      }
    })
  }
}
// 取消确定价格
const cancelPriceIm = () => {
  resetpriceForm()
  priceImportO.value = false
}
// 重置批量修改等级
const resetCustomerLevel = () => {
  (gradeForm.value = {
    grade: undefined,
  })
  $resetForm(customerLevel.value)
}
/* 提交批量 */
const submitCustomerLevel = () => {
  if (!gradeForm.value.grade) {
    ElMessage.error('价格必选')
    return
  }
  const data = {
    grade: gradeForm.value.grade,
    ids: ids.value,
  }
  updataGrade(data).then((res) => {
    if (res.code == 200) {
      ElMessage.success(res.msg)
      priceOpen.value = false
      handleQuery()
      resetCustomerLevel()
    }
  })
}
// 取消批量提交等级
const cancelCustomerLevel = () => {
  resetCustomerLevel()
  priceOpen.value = false
}
// 设置特殊产品
const handleSpecialProduct = () => {
  specialOpen.value = true
  specialTitle.value = '特殊产品管理'
}
/** 客户状态修改  */
const emit = defineEmits(['update:modelValue'])
// 修改状态
const handleStatusChange = (row: { [key: string]: any }) => {
  const text = row.status == '0' ? '启用' : '停用'
  ElMessageBox.confirm(`确认要"${ text }""${ row.customerCode }"客户吗?`, '警告', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
  .then(() => editCustStatus(row.customerCode))
  .then((res) => {
    if (res.code == 200) {
      row.status = row.status === '0' ? '1' : '0'   
      ElMessage.success(`${ text }成功`)
    } else {
      row.status = row.status === '0' ? '1' : '0'
      ElMessage.success(`${ text }失败`)
    }
  })
  .catch((error) => {
    if (error === 'cancel') {
      ElMessage.info('取消操作')
    }
  })
}
/* 新增修改客户信息-----start */
const setFormRef = ref(null)
const handleAddSpecial = () => {
  setFormRef.value.openCustomeInfo = true
  setFormRef.value.addTitle = '新增客户信息'
}
const handleUpdate = (row) => {
  setFormRef.value.openCustomeInfo = true
  setFormRef.value.addTitle = '修改客户信息'
  setFormRef.value.idss = productId.value || row.id
  setFormRef.value.getList()
}
/* 新增修改客户信息------end */

const mainConfig = computed({
  get() {
    return {
      query: {
        fields: [
          {
            label: '客户代码',
            prop: 'customerCode',
            width: '240',
            option: {
              placeholder: '请输入客户代码',
              clearable: true,
           
            },
          },
          {
            label: '客户全称',
            prop: 'wholeName',
            width: '240',
            option: {
              placeholder: '请输入客户全称',
              clearable: true,
     
            },
          },
          {
            label: '客户简称',
            prop: 'customerName',
            width: '240',
            option: {
              placeholder: '请输入客户简称',
              clearable: true,
        
            },
          },
          {
            label: '业务员',
            prop: 'businessManager',
            width: '240',
            option: {
              placeholder: '请输入业务员',
              clearable: true,
  
            },
          },
          {
            label: '状态',
            type: 'select',
            prop: 'status',
            width: '240',
            option: {
              placeholder: '请输入客户状态',
              clearable: true,
              dictInfo: {
                dict: DictDirection.通用状态,
              },
            },
          },
          {
            label: '客户等级',
            type: 'select',
            prop: 'grade',
            width: '240',
            option: {
              placeholder: '请输入客户等级',
              clearable: true,
              dictInfo: {
                dict: DictDirection.价格等级,
              },
            },
          },
          {
            type: 'date-picker',
            label: '创建时间',
            prop: 'dateRange',
            option: {
              type: 'daterange',
            },
          },
        ],
        queryParams: queryParams.value,
      },
      btns: [
        {
          title: '特殊新增',
          directive: [['hasPermi', ['system:clientManger:add']]],
          onClick: handleAddSpecial,
          icon: Plus,
        },
        {
          title: '修改',
          directive: [['hasPermi', ['system:clientManger:edit']]],
          type: 'success',
          disabled: single.value,
          icon: Edit,
          onClick: handleUpdate,
        },
        {
          title: '删除',
          directive: [['hasPermi', ['system:clientManger:remove']]],
          onClick: handleDelete,
          type: 'danger',
          disabled: multiple.value,
          icon: Delete,
        },
        {
          title: '设置特殊产品',
          directive: [['hasPermi', ['system:custWeighing:list']]],
          onClick: handleSpecialProduct,
          type: 'warning',
          disabled: single.value,
        },
        {
          title: '账期',
          directive: [['hasPermi', ['system:clientManger:queryModel']]],
          onClick: handleTransportType,
          type: 'info',
          disabled: single.value,
        },
        {
          title: '设置临时账期',
          directive: [['hasPermi', ['system:clientManger:queryModel']]],
          onClick: handleIntermTransportType,
          type: 'success',
          disabled: single.value,
        },
        {
          title: '批量修改客户等级',
          onClick: handleEditPrice,
          type: 'primary',
          disabled: multiple.value,
        },
        {
          title: '导出客户信息',
          onClick: handleExport,
          type: 'warning',
        },
        {
          title: '价格关联',
          onClick: handlePriceImport,
          type: 'success',
          disabled: multiple.value,
        },
        {
          title: '修改可预定方数',
          onClick: handleQuantity,
          type: 'warning',
          disabled: multiple.value,
          directive: [['hasPermi', ['system:clientManger:modifyBooking']]],
        },
        {
          title: '批量修改业务员',
          onClick: handleEditSalesman,
          type: 'warning',
          disabled: multiple.value,
          directive: [['hasPermi', ['system:clientManger:batchEidtBusinessManager']]],
        },
      ],
      table: {
        columns: [
          {
            type: 'selection',
            minWidth: '55',
            align: 'center',
          },
          {
            label: '客户代码',
            prop: 'customerCode',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '客户简称',
            prop: 'customerName',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '客户全称',
            prop: 'wholeName',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '创建时间',
            prop: 'createDate',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '状态',
            prop: 'status',
            minWidth: '100',
            align: 'center',
            directive: [['hasPermi', ['system:clientManger:editCustStatus'], 'switch']],
            autoFormatter: {
              dict: DictDirection.是否禁用字典,
              rowKey: 'status',
            },
            render(h, params) {
              return h(ElSwitch, {
                onClick: () => {
                  handleStatusChange(params.row)
                  console.log('handleStatusChange', params)
                },
                modelValue: params.row.status,
                'onUpdate:modelValue': (value) => {
                  emit('update:modelValue', value)
                },
                activeValue: '0',
                inactiveValue: '1',
                activeColor: '#C0CCDA',
                inactiveColor: '#409EFF',
              })
            },
          },
          {
            label: '类型',
            prop: 'type',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.客户类型,
              rowKey: 'type',
            },
          },
          {
            label: '客户等级',
            prop: 'grade',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.价格等级,
              rowKey: 'grade',
            },
          },
          {
            label: '地址',
            prop: 'address',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '电话',
            prop: 'telephone',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '邮箱',
            prop: 'email',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '结算模式',
            prop: 'settlementModel',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.客户结算模式,
              rowKey: 'settlementModel',
            },
          },
          {
            label: '分区代码',
            prop: 'partitionCode',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '所属机构',
            prop: 'areaCode',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.收货站点,
              rowKey: 'areaCode',
            },
          },
          {
            label: '业务员',
            prop: 'businessManager',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '客服员',
            prop: 'customerService',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '结算员',
            prop: 'settlementClerk',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '提货员',
            prop: 'deliveryMan',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '余额',
            prop: 'balance',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '负责人',
            prop: 'chargePerson',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '负责人手机号',
            prop: 'chargePersonTel',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '佣金',
            prop: 'commission',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '录单状态',
            prop: 'recordingStatus',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.客户端开关,
              rowKey: 'recordingStatus',
            },
          },
          {
            label: '是否开通客户端',
            prop: 'isOpenAccount',
            minWidth: '100',
            align: 'center',
            autoFormatter: {
              dict: DictDirection.客户端开关,
              rowKey: 'isOpenAccount',
            },
          },
          {
            label: '价格表id',
            prop: 'priceId',
            minWidth: '100',
            align: 'center',
          },
          {
            label: '操作',
            align: 'center',
            showOverflowTooltip: false,
            fixed: 'right',
            minWidth: '230',
            className: 'custormFixedCol',
            render: (h, params) => {
              const buttons = [
                {
                  title: '修改',
                  clickFun: handleUpdate,
                  directive: [['hasPermi', ['system:clientManger:edit']]],
                },
                {
                  title: '删除',
                  clickFun: handleDelete,
                  directive: [['hasPermi', ['system:clientManger:remove']]],
                },
                {
                  title: '末端额度充值',
                  clickFun: handleRecharge,
                  directive: [['hasPermi', [' system:clientManger:reCharge']]],
                },
                {
                  title: '下载价格',
                  clickFun: handleDownPriceExcl,
                },
              ]
              return buttons.map((el) => h(
                ElButton,
                {
                  text: true,
                  type: 'primary',
                  onClick: () => {
                    el.clickFun(params.row)
                  },
                },
                {
                  default: () => el.title,
                },
              ))
            },
          },
        ],
        event: {
          onSelectionChange: (rows) => {
            handleTableSelect(rows)
          },
        },
      },
      api: getData,
    }
  },
  set(v) {
    return v
  },
})

</script>
